﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DecoratorPattern;

/// <summary>
/// 公开课 Student class.
/// </summary>
public class StudentFree : AbstructStudent
{
    public override void Study()
    {
        Console.WriteLine("Free student studying...");

        // 新需求：获取视频+课件+代码的会看 需要修改现有代码
        //Console.WriteLine("获取视频+课件+代码的会看");
    }
}

/// <summary>
/// 这个是通过继承的方式来实现在不修改原有代码的情况下，动态地添加新的功能或行为。
/// </summary>
public class StudentFreeVideo : StudentFree
{
    public override void Study()
    {
        base.Study();
        Console.WriteLine("获取视频+课件+代码的会看");
    }
}

/// <summary>
/// 通过组合的方式来实现在不修改原有代码的情况下，动态地添加新的功能或行为。
/// </summary>
public class StudentCombination
{
    private readonly AbstructStudent _abstructStudent;

    public StudentCombination(AbstructStudent abstructStudent)
    {
        _abstructStudent = abstructStudent;
    }

    public void Study()
    {
        _abstructStudent.Study();
        Console.WriteLine("获取视频+课件+代码的会看");
    }
    public void Show()
    {
        _abstructStudent.Show();
    }
}
